Mutable data
코드 악취 중 하나.
관련 리팩토링
- Encapsulate variable
- Split variable
- Slide statements
- Extract function
- Separate query from modifier
- Remove setting method
- Replace derived variable with query
- Combine functions into class
- Combine functions into transform
- Change reference to value
함수형 프로그래밍
변하는 데이터 그 자체를 문제의 원인으로 보는 접근:
For this reason, an entire school of software development—functional programming—is based on the notion that data should never change and that updating a data structure should always return a new copy of the structure with the change, leaving the old data pristine. —Chapter 3, Refactoring: Improving the design of existing code
(모든 함수형 프로그래밍이 변수를 허용하지 않는 건 아니다.)